package faas

import (
	"context"
	"flow-calc/core"
	"flow-calc/core/log"
	"fmt"
)

func FuncDemoOne(ctx context.Context, flow core.Flow) error {
	log.Logger().Info("---------------------%s------------------", "FuncDemoOne")
	log.Logger().Info("获取全部的自定义参数缓存: %+v", flow.GetFuncParamAll())
	for index, row := range flow.Input() {
		log.Logger().Info("In FuncName = %s, FuncId = %s, row = %s", flow.GetExecFuncConf().FName, flow.GetExecFunction().GetId(), row)
		// 提交计算结果数据
		_ = flow.CommitRow(fmt.Sprintf("上一层函数: %s, 第几个参数: %d", flow.GetExecFuncConf().FName, index))
	}
	return nil
}

func FuncDemoTwo(ctx context.Context, flow core.Flow) error {
	log.Logger().Info("---------------------%s------------------", "FuncDemoTwo")
	log.Logger().Info("获取全部的自定义参数缓存: %+v", flow.GetFuncParamAll())
	for index, row := range flow.Input() {
		log.Logger().Info("In FuncName = %s, FuncId = %s, row = %s", flow.GetExecFuncConf().FName, flow.GetExecFunction().GetId(), row)
		// 提交计算结果数据
		_ = flow.CommitRow(fmt.Sprintf("上一层函数: %s, 第几个参数: %d", flow.GetExecFuncConf().FName, index))
	}
	return nil
}

func FuncDemoThree(ctx context.Context, flow core.Flow) error {
	log.Logger().Info("---------------------%s------------------", "FuncDemoThree")
	log.Logger().Info("获取全部的自定义参数缓存: %+v", flow.GetFuncParamAll())
	for index, row := range flow.Input() {
		log.Logger().Info("In FuncName = %s, FuncId = %s, row = %s", flow.GetExecFuncConf().FName, flow.GetExecFunction().GetId(), row)
		// 提交计算结果数据
		_ = flow.CommitRow(fmt.Sprintf("上一层函数: %s, 第几个参数: %d", flow.GetExecFuncConf().FName, index))
	}
	return nil
}
